home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
-
-
- #------------------------------------------------------------
- $js_check_int =
- "function checkInt(check, base) {
- if (base == 10) word = \"0123456789\";
- else if (base == 16) word = \"0123456789abcdefABCDEF\";
- else return (false);
-
- for (i=0; i<check.length; i++)
- if (word.indexOf(check.charAt(i)) == -1) return (false);
- return (true);
- }
- function checkInt_c(check, base) {
- if (base == 10) word = \"0123456789\";
- else if (base == 16) word = \"0123456789abcdefABCDEF\";
- else return (false);
-
- if (word.indexOf(check) == -1) return (false);
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_account_main =
- "which = \"none\";
- function runSubmit() {
- if(which == \"add\") return runAdd();
- if(which == \"edit\") return runEdit();
- if(which == \"delete\") return runDelete();
- return (true);
- }
- function markAdd() { which = \"add\"; }
- function markEdit() { which = \"edit\"; }
- function markDelete() { which = \"delete\"; }
- function markOther() { which = \"none\"; }
- function runAdd() {
- form = document.AccountForm
- if (!testAdd(form)) return (false);
- return (true);
- }
- function runEdit() {
- Ctrl = document.AccountForm.chosen
- none = true;
- for(j = 0; j < Ctrl.length; j++) {
- if (Ctrl.options[j].selected) { none = false; break; }
- }
- if (none) {
- errorBox (Ctrl, \"To edit an existing \" + type + \", \"
- + \"first select an \" + type + \"\\nfrom the list, \"
- + \"then click the edit button.\");
- return (false);
- }
- return (true);
- }
- function runDelete() {
- Ctrl = document.AccountForm.chosen;
- none = true;
- for(j = 0; j < Ctrl.length; j++) {
- if (Ctrl.options[j].selected) { none = false; break; }
- }
- if (none) {
- errorBox (Ctrl, \"To delete an existing \" + type + \", first \"
- + \"select an \" + type + \"\\nfrom the list, then click \"
- + \"the delete button.\");
- return (false);
- }
- return (true);
- }";
-
- #------------------------------------------------------------
- $js_account_add =
- "which = \"none\";
- function runSubmit() {
- if(which == \"add\") return runAdd();
- return (true);
- }
- function markAdd() { which = \"add\"; }
- function markOther() { which = \"none\"; }
- function runAdd() {
- form = document.AddForm;
- if (!testAdd(form)) return (false);
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_account_edit =
- "which = \"none\";
- function runSubmit() {
- if(which == \"edit\") return runEdit();
- return (true);
- }
- function markEdit() { which = \"edit\"; }
- function markOther() { which = \"none\"; }
- function runEdit() {
- form = document.EditForm;
- if (!testEdit(form)) return (false);
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_standard =
- "which = \"none\";
- function runSubmit() {
- if(which == \"ok\") return runOK();
- return (true);
- }
- function markOK() { which = \"ok\"; }
- function markOther() { which = \"none\"; }
- function runOK() {
- form = document.StandardForm;
- if (!checkForm(form)) return (false);
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_error_box =
- "function errorBox (Ctrl, ErrorMessage) {
- alert (ErrorMessage); Ctrl.focus(); return;
- }";
-
-
- #------------------------------------------------------------
- $js_phone =
- "$js_check_int
- function testPhone(Ctrl) {
- if (Ctrl.value == \"\") {
- errorBox (Ctrl, \"The phone number is required.\");
- return (false);
- }
- error = testPhoneChars(Ctrl.value);
- if (error == 1) {
- errorBox (Ctrl, \"The phone number cannot contain spaces.\");
- return (false);
- }
- if (error == 2) {
- errorBox (Ctrl, \"The phone number cannot contain \"
- + \"\\nletters or punctuation.\");
- return (false);
- }
- return (true);
- }
- function testPhoneChars(word) {
- for(i = 0; i < word.length; i++) {
- c = word.charAt(i);
- if (c == ' ') return 1;
- if (c != \'(\' && c != \')\' && c != \'-\' && c != \',\') {
- if (! checkInt_c(c, 10)) return 2;
- // num = parseInt(c);
- // if(isNaN(num)) return 2;
- }
- }
- return 0;
- }";
-
-
- #------------------------------------------------------------
- $js_meta =
- "function testMeta(Ctrl, what) {
- if (Ctrl.value == \"\") {
- errorBox (Ctrl, \"The \" + what + \" is required.\");
- return (false);
- }
- error = testMetaChars(Ctrl.value);
- if (error == 1) {
- errorBox (Ctrl, \"The \" + what + \" cannot be more \"
- + \"\\nthan 8 characters long.\");
- return (false);
- }
- if (error == 2) {
- errorBox (Ctrl, \"The \" + what + \" cannot contain \"
- + \"the \" + illegal + \" character.\");
- return (false);
- }
- if (error == 3) {
- errorBox (Ctrl, \"The \" + what + \" cannot contain \"
- + \"spaces.\");
- return (false);
- }
- return (true);
- }
- function testMetaChars(word) {
- if (word.length > 8) return 1;
- loginChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
- for(j = 0; j < loginChars.length; j++) {
- c = loginChars.charAt(j);
- if (word.indexOf(c, 0) != -1) { illegal = c; return 2; }
- }
- for (c = 0; c < word.length; c++) {
- if (word.charAt(c) == ' ') return 3;
- }
- return 0;
- }";
-
-
- #------------------------------------------------------------
- $js_iplist =
- "function testIPList(Ctrl, what) {
- my_count = 0;
- whitespace = \" \\n\\r\\t\\f\"; space = true;
- for(start=0, cur=0; cur < Ctrl.value.length; cur++) {
- for(i = 0; i < whitespace.length; i++) {
- c = whitespace.charAt(i);
- if (Ctrl.value.charAt(cur) == c) { // found whitespace
- if (space == false) {
- space = true;
- if(cur != start) {
- host = Ctrl.value.substring(start,cur);
- // if (flag == 1) host = host.indexOf(':',0);
- my_count++;
- if (!testIPaddress(host,false)) {
- errorBox (Ctrl, \"Invalid \" + what + \": \" + host);
- return (false);
- }
- }
- }
- break;
- } else { // found character
- if (space == true) {
- space = false;
- start = cur;
- }
- }
- }
- }
- if(cur != start && space == false) {
- host = Ctrl.value.substring(start,cur);
- // if (flag == 1) host = host.indexOf(':',0);
- my_count++;
- if (!testIPaddress(host,false)) {
- errorBox (Ctrl, \"Invalid \" + what + \": \" + host
- + \"\\nin \" + what + \" list.\");
- return (false);
- }
- }
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_ip =
- "$js_check_int;
- function testIPaddress(address, netmask) {
- start = 0;
- while ((address.charAt(start) == ' ') || (address.charAt(start) == '\t')) {
- start++;
- }
-
- end = address.length - 1;
- while ((end > 0) && ((address.charAt(end) == ' ') || (address.charAt(end) == '\t'))) {
- end--;
- }
-
- if ((start > 0) && (end == 0)) {
- return (false);
- }
-
- if (address.substring(start, start + 2) == \"0x\") {
- if (! checkInt(address.substring(start + 2, end), 16)) return (false);
- // if (isNaN(parseInt(address.substring(start + 2, end), 16))) {
- // return (false);
- // }
- if (netmask) {
- for (state = 0, start += 2; start <= end; start++) {
- value = address.charAt(start);
- if (value == 'f') {
- if (state != 0) {
- return (false);
- }
- } else if ((value == 'c') || (value == 'e')) {
- if (state != 0) {
- return (false);
- }
- state = 1;
- } else if (value == '0') {
- state = 1;
- } else {
- return (false);
- }
- }
- }
- return (true);
- }
-
- for (state = 0, count = 0; start <= end; count++) {
- dot = address.indexOf('.', start);
- if (dot < 0) {
- dot = end + 1;
- } else if (dot == 0 || dot == end) {
- return (false);
- }
- // if (isNaN(parseInt(address.substring(start, dot), 10))) {
- if (! checkInt(address.substring(start, dot), 10)) {
- return (false);
- }
- value = parseInt(address.substring(start, dot), 10);
- if (netmask) {
- if (value == 255) {
- if (state != 0) {
- return (false);
- }
- } else if ((value == 254) || (value == 252) ||
- (value == 248) || (value == 240) || (value == 224) ||
- (value == 192) || (value == 128)) {
- if (state != 0) {
- return (false);
- }
- state = 1;
- } else if (value == 0) {
- state = 1;
- } else {
- return (false);
- }
- }
- if ((value > 255) || (value < 0)) {
- return (false);
- }
- start = dot + 1;
- }
- if (count > 4) {
- return (false);
- }
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_hostlist =
- "function testHostlist(Ctrl, what) {
- whitespace = \" \\n\\r\\t\\f\"; space = true;
- for(start=0, cur=0; cur < Ctrl.value.length; cur++) {
- for(i = 0; i < whitespace.length; i++) {
- c = whitespace.charAt(i);
- if (Ctrl.value.charAt(cur) == c) { // found whitespace
- if (space == false) {
- space = true;
- if(cur != start) {
- host = Ctrl.value.substring(start,cur);
- if (!testHostname(Ctrl, host, what, 0)) return (false);
- }
- }
- break;
- } else { // found character
- if (space == true) {
- space = false;
- start = cur;
- }
- }
- }
- }
- if(cur != start && space == false) {
- host = Ctrl.value.substring(start,cur);
- if (!testHostname(Ctrl, host, what, 0)) return (false);
- }
- return (true);
- }";
-
-
- #------------------------------------------------------------
- $js_hostname =
- "$js_check_int;
- function testHostname(Ctrl, host, what, flag) {
- if (host == \"\") {
- if (flag == 1) return (true);
- errorBox (Ctrl, \"The \" + what + \" is required.\");
- return (false);
- }
- error = testHost(host);
- if (error == 1) {
- errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain \"
- + illegal + \" characters.\");
- return (false);
- }
- if (error == 2) {
- errorBox (Ctrl, \"The \" + what + \" cannot start or \\n \"
- + \"end with a . or - or _ character.\");
- return (false);
- }
- if (error == 3) {
- errorBox (Ctrl, \"The \" + what + \" cannot contain \\n\"
- + \"consecutive . or - or _ characters.\");
- return (false);
- }
- if (error == 4) {
- errorBox (Ctrl, \"The \" + what + \" cannot contain spaces.\");
- return (false);
- }
- if (error == 5) {
- errorBox (Ctrl, \"The \" + what + \" cannot begin \\nwith \"
- + \"a number.\");
- return (false);
- }
- return (true);
- }
- function testHost(word) {
- metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
- start = 0;
- while (word.charAt(start) == ' ') { start++; }
- end = word.length-1;
- while (word.charAt(end) == ' ') { end--; }
- for(j = 0; j < metaChars.length; j++) {
- c = metaChars.charAt(j);
- i = word.indexOf(c, 0);
- if (i != -1) { illegal = c; return 1; }
- }
- sch = word.charAt(start); ech = word.charAt(end);
- if(sch == '.' || sch == '-' || sch == '_') return 2;
- if(ech == '.' || ech == '-' || ech == '_') return 2;
- for(j = start; j <= end; j++) {
- ch = word.charAt(j);
- if (ch == '.' || ch == '-' || ch == '_') {
- if (word.charAt(j+1) == ch) return 3;
- } if (ch == ' ') { return 4; }
- }
- if (checkInt(sch, 10)) return 5;
- // if(!isNaN(parseInt(sch))) return 5;
- return 0;
- }";
-
-
- #------------------------------------------------------------
- $js_filename =
- "function testFilename(Ctrl, what) {
- word = Ctrl.value;
- if (word == \"\") {
- errorBox (Ctrl, \"The \" + what + \" is required.\");
- return (false);
- }
- if (!testFileChars(word)) {
- errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain \"
- + illegal + \" characters.\");
- return (false);
- }
- for(i = 0; i < word.length; i++) {
- if (word.charAt(i) == ' ') {
- errorBox (Ctrl, \"The \" + what + \" cannot \\ncontain spaces.\");
- return (false);
- }
- }
- if (word.charAt(0) != '/') {
- errorBox (Ctrl, \"The \" + what + \" must be fully qualified.\");
- return (false);
- }
- return (true);
- }
- function testFileChars(word) {
- metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\";
- for(j = 0; j < metaChars.length; j++) {
- illegal = metaChars.charAt(j);
- if (word.indexOf (illegal, 0) != -1) return (false);
- } return (true);
- }";
-